Skip to content

Conversation

@Maokaman1
Copy link
Contributor

@Maokaman1 Maokaman1 commented Oct 16, 2025

Closes #40097

When multiple files are added sequentially to the agent panel, the request JSON incorrectly includes "text" elements containing only spaces. These empty elements cause the Zhipu AI API to return a "text cannot be empty" error.
The fix filters out any "text" elements that are empty or contain only whitespaces.

UI state when the error occurs:
Image

Request JSON (causing the error):

{
  "model": "glm-4.6",
  "messages": [
    {
      "role": "system",
      "content": "<<CUT>>"
    },
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "[@1.txt](zed:///agent/file?path=C%3A%5CTemp%5CTest%5C1.txt)"
        },
        { "type": "text", "text": " " },
        {
          "type": "text",
          "text": "[@2.txt](zed:///agent/file?path=C%3A%5CTemp%5CTest%5C2.txt)"
        },
        { "type": "text", "text": " describe" },

Release Notes:

  • Filter out whitespace-only text content parts for OpenAI and OpenAI compatible providers

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Oct 16, 2025
@SomeoneToIgnore SomeoneToIgnore added the ai Improvement related to Agent Panel, Edit Prediction, Copilot, or other AI features label Oct 16, 2025
@bennetbo bennetbo self-assigned this Nov 3, 2025
@bennetbo bennetbo merged commit 160bf91 into zed-industries:main Nov 7, 2025
24 checks passed
@bennetbo
Copy link
Member

bennetbo commented Nov 7, 2025

Thank you!

tomatitito pushed a commit to tomatitito/zed that referenced this pull request Nov 7, 2025
…enAI and OpenAI compatible providers (zed-industries#40316)

Closes zed-industries#40097

When multiple files are added sequentially to the agent panel, the
request JSON incorrectly includes "text" elements containing only
spaces. These empty elements cause the Zhipu AI API to return a "text
cannot be empty" error.
The fix filters out any "text" elements that are empty or contain only
whitespaces.

UI state when the error occurs:
<img width="300" alt="Image"
src="https://github.com/user-attachments/assets/c55e5272-3f03-42c0-b412-fa24be2b0043"
/>

Request JSON (causing the error):
```
{
  "model": "glm-4.6",
  "messages": [
    {
      "role": "system",
      "content": "<<CUT>>"
    },
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "[@1.txt](zed:///agent/file?path=C%3A%5CTemp%5CTest%5C1.txt)"
        },
        { "type": "text", "text": " " },
        {
          "type": "text",
          "text": "[@2.txt](zed:///agent/file?path=C%3A%5CTemp%5CTest%5C2.txt)"
        },
        { "type": "text", "text": " describe" },
```

Release Notes:

- Fixed an issue when an OpenAI request contained whitespace-only text content

Co-authored-by: Bennet Bo Fenner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai Improvement related to Agent Panel, Edit Prediction, Copilot, or other AI features cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AI: Zhipu AI returns "text cannot be empty" when using multiple context files

3 participants